<template>
  <div>
    <router-link to="/uptime/AddUptime" v-if="role==2"><el-button>添加</el-button></router-link>
    <el-table
      :data="uptimeList"
      :stripe="true"
      style="width: 100%">
      <el-table-column
        prop="id"
        label="编号">
      </el-table-column>
      <el-table-column
        label="用户名称">
        <template slot-scope="scope">
          {{scope.row.member.name}}
        </template>
      </el-table-column>
      <el-table-column
        prop="startTime"
        label="开始时间">
      </el-table-column>
      <el-table-column
        prop="endTime"
        label="结束时间">
      </el-table-column>
      <el-table-column
        prop="createTime"
        label="创建时间">
      </el-table-column>

      <el-table-column
        prop="description"
        label="描述">
      </el-table-column>

    </el-table>
    <router-view/>
  </div>
</template>

<script>
    export default {
        name: "uptimeList",
      data(){
          return {
            uptimeList:[],
            role:sessionStorage.getItem("role")
          }
      },
      created(){
        this.selectAll();
      },
      methods:{
        selectAll() {
          //发出ajax请求请求后端代码
          let url = "/uptime/selectAll";
          if (this.$route.query.cid) {
            url += "?cid=" + this.$route.query.cid;
          }
          this.axios.get(url).then((resp) => {
            this.uptimeList = resp.data;
          });
        }
      }
    }
</script>

<style scoped>

</style>
